<?php
include("admin_check.php");
include_once("../function.php");
include_once ("../bonus.php");
session_start();
header("Content-Type: text/html;charset=utf-8");
checkqx(2,13);
#搜索会员
if ($_POST['Search']){
    $SearchContent=$_POST['SearchContent'];
    $TimeStart=$_POST['TimeStart'];
    $TimeEnd=$_POST['TimeEnd'];
    $SearchType=$_POST['SearchType'];
    if ($TimeStart!=NULL){
        if ($TimeEnd==NULL){
            $TimeEnd=now();
        }
        $_SESSION['SearchTime']="and zdate>='".$TimeStart."' and zdate<='".$TimeEnd."'";
    }else{
        $_SESSION['SearchTime']=NULL;
    }
    if ($SearchContent!=NULL){
        if ($SearchType==1){
            #搜索会员编号
            $_SESSION['Search']="and nickname='".$SearchContent."'";
        }
    }else{
        if ($SearchType==1){
            $_SESSION['Search']=NULL;
        }elseif($SearchType==2){
            #搜索电子币
            $_SESSION['Search']="and lx=0";
        }elseif($SearchType==3){
            #搜索购物币
            $_SESSION['Search']="and lx=1";
        }
    }
}else{
    if ($_GET['page']==NULL){
        $_SESSION['Search']=NULL;
        $_SESSION['SearchTime']=NULL;
    }
}

#删除记录
if ($_POST['button4']){
    $cheuid_arr = $_POST['UID'];
    foreach ((array)$cheuid_arr as $id)
    {
        edit_delete_cl('zhuanhuan',$id);
    }
    alert("删除完成","?");
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/table.css" rel="stylesheet" type="text/css">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <script src="../js/calendar.js"></script>
    <link href="../layui-master/dist/css/layui.css" rel="stylesheet" type="text/css">
    <script src="../layui-master/dist/layui.js"></script>
    <title>提现管理</title>
    <script>
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#TimeStart' //指定元素
            });
            laydate.render({
                elem: '#TimeEnd' //指定元素
            });
        });
    </script>
    <SCRIPT LANGUAGE=javascript>
        <!--
        function SelectAll() {
            for (var i=0;i<document.form1.UID.length;i++) {
                var e=document.form1.UID[i];
                e.checked=!e.checked;
            }
        }
        -->
    </script>
    <script language="javascript">
        <!--
        //导出excel
        function exportExcel(DivID){
            var oXL = new ActiveXObject("Excel.Application");
            var oWB = oXL.Workbooks.Add();
            var oSheet = oWB.ActiveSheet;
            var sel=document.body.createTextRange();
            sel.moveToElementText(daochu);
            sel.select();
            sel.execCommand("Copy");
            oSheet.Paste();
            oXL.Visible = true;
        }
        -->
    </script>
</head>
<body>
<form name="form1" method="post" action="?">
    <table width="100%" cellpadding="3" cellspacing="0" border="0" align="center" class="layui-table" lay-skin="line">
        <tr>
            <td height="4" align="left">
                <select name="SearchType" id="SearchType">
                    <option value="1">会员编号</option>
                    <!--            <option value="2">电子币</option>-->
                    <!--  <option value="3">购物币</option> -->
                </select>
                <input type="text" name="SearchContent" id="SearchContent">
                <input type="submit" name="Search" id="Search" class="layui-btn layui-btn-small" value="搜索"></td>
            <td height="4" align="center"><input type="button" name="dayin" id="dayin" class="layui-btn layui-btn-small" value="导出表格" onClick="window.location.href='excel.php?table=zhuanhuan'"></td>
        </tr>
        <tr>
            <td height="5" colspan="2" align="left">搜索时间范围：
                <input type="text" name="TimeStart" id="TimeStart" style="width:100px" >
                至
                <input type="text" name="TimeEnd" id="TimeEnd" style="width:100px" ></td>
        </tr>
        <tr><td colspan="2">
                <table width="100%" cellpadding="0" cellspacing="1" border="0" align="center" class="layui-table" lay-skin="line" id="daochu">
                    <tr>
                        <td height="10" colspan="16" align="center"> 转 换 记 录</td>
                    </tr>
                    <tr>
                        <td height="21" align="center"><input type="checkbox" name="checkbox" value="checkbox" onClick="javascript:SelectAll()"></td>
                        <td align="center">会员编号</td>
                        <td align="center">会员姓名</td>
                        <td align="center">转换金额</td>
                        <td align="center">服务费</td>
                        <td align="center">公益基金</td>
                        <td align="center">消费积分</td>
                        <td align="center">实体基金</td>
                        <td align="center">申请类型</td>
                        <td align="center">转换时间</td>

                    </tr>
                    <?php
                    $pagesize = 20; //设置每页记录数
                    $sql = "SELECT * FROM `zhuanhuan` WHERE 1=1 ".$_SESSION['Search']." ".$_SESSION['SearchTime']."";
                    if($query = mysql_query($sql)){
                        $sum = mysql_num_rows($query); //计算总记录数
                    }else{
                        $sum=0;
                    }
                    if($sum % $pagesize == 0) //计算总页数
                        $total = (int)($sum/$pagesize);
                    else
                        $total = (int)($sum/$pagesize) + 1;
                    if (isset($_GET['page'])) //获得页码
                    {
                        $p = (int)$_GET['page'];
                    }
                    else
                    {
                        $p = 1;
                    }
                    if ($p>$total){
                        $p=$total;
                    }
                    $start = $pagesize * ($p - 1); //计算起始记录
                    $sql = "SELECT * FROM `zhuanhuan` WHERE 1=1 ".$_SESSION['Search']." ".$_SESSION['SearchTime']." order by zdate desc limit ".$start.",".$pagesize;
                    if($query = mysql_query($sql)){
                        while ($row=mysql_fetch_array($query)){
                            ?>
                            <tr>
                                <td height="21" align="center"><input type="checkbox" name="UID[]" id="UID" value="<?=$row['id']?>"></td>
                                <td align="center"><?=$row['nickname']?></td>
                                <td align="center"><?=$row['username']?></td>
                                <td align="center"><?=$row['jine']?></td>
                                <td align="center"><?=$row['jinzhongzi']?></td>
                                <td align="center"><?=$row['zonghe']?></td>
                                <td align="center"><?=$row['csjjmey']?></td>
                                <td align="center"><?=$row['st']?></td>
                                <td align="center"><?php if ($row['lx']==0){ echo $zhuanghuanlx1; }elseif($row['lx']==1){ echo $zhuanghuanlx2; }elseif($row['lx']==2){ echo $zhuanghuanlx3; }elseif($row['lx']==3){?>电子币转充值积分<?php }elseif($row['lx']==4){?>专用币转积分<?php }?></td>
                                <td align="center"><?=$row['zdate']?></td>
                            </tr>
                            <?php
                        }
                    }
                    ?>
                </table>
            </td>
        </tr>
        <tr>
            <td height="21" colspan="2" align="right">
                <table width="100%" border="0">
                    <tr>
                        <td align="left"><input name="button4" type="submit" class="layui-btn layui-btn-radius layui-btn-danger" id="button4" value="删除记录" onClick="{if(confirm('您确定要删除该记录吗?')){this.document.selform.submit();return true;}return false;}"></td>
                        <td align="right"><?php echo fenye($p,$pagesize,$sum,$total,$cx)?></td>
                    </tr>
                </table></td>
        </tr>
    </table>
</form>
</body>
</html>